package com.ruoyi.web.controller.workSafetyStandardization.inspection;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.workSafetyStandardization.domain.InspectionStandardResult;
import com.ruoyi.workSafetyStandardization.service.IInspectionStandardResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 标准化考核--标准考核得分Controller
 *
 * @author pengjie
 * @date 2023-12-18
 */
@RestController
@RequestMapping("/workSafetyStandardization/InspectionStandardResult")
public class InspectionStandardResultController extends BaseController
{
    @Autowired
    private IInspectionStandardResultService inspectionStandardResultService;

    /**
     * 查询标准化考核--标准考核得分列表
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionStandardResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(InspectionStandardResult inspectionStandardResult)
    {
        startPage();
        List<InspectionStandardResult> list = inspectionStandardResultService.selectInspectionStandardResultList(inspectionStandardResult);
        return getDataTable(list);
    }

    /**
     * 导出标准化考核--标准考核得分列表
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionStandardResult:export')")
    @Log(title = "标准化考核--标准考核得分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InspectionStandardResult inspectionStandardResult)
    {
        List<InspectionStandardResult> list = inspectionStandardResultService.selectInspectionStandardResultList(inspectionStandardResult);
        ExcelUtil<InspectionStandardResult> util = new ExcelUtil<InspectionStandardResult>(InspectionStandardResult.class);
        util.exportExcel(response, list, "标准化考核--标准考核得分数据");
    }

    /**
     * 获取标准化考核--标准考核得分详细信息
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionStandardResult:query')")
    @GetMapping(value = "/{standardResultId}")
    public AjaxResult getInfo(@PathVariable("standardResultId") String standardResultId)
    {
        return success(inspectionStandardResultService.selectInspectionStandardResultByStandardResultId(standardResultId));
    }

    /**
     * 新增标准化考核--标准考核得分
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionStandardResult:add')")
    @Log(title = "标准化考核--标准考核得分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InspectionStandardResult inspectionStandardResult)
    {
        return toAjax(inspectionStandardResultService.insertInspectionStandardResult(inspectionStandardResult));
    }

    /**
     * 修改标准化考核--标准考核得分
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionStandardResult:edit')")
    @Log(title = "标准化考核--标准考核得分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InspectionStandardResult inspectionStandardResult)
    {
        return toAjax(inspectionStandardResultService.updateInspectionStandardResult(inspectionStandardResult));
    }

    /**
     * 删除标准化考核--标准考核得分
     */
    @PreAuthorize("@ss.hasPermi('workSafetyStandardization:InspectionStandardResult:remove')")
    @Log(title = "标准化考核--标准考核得分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{standardResultIds}")
    public AjaxResult remove(@PathVariable String[] standardResultIds)
    {
        return toAjax(inspectionStandardResultService.deleteInspectionStandardResultByStandardResultIds(standardResultIds));
    }
}
